package com.traffic.managent.model.product;

import java.util.List;

import com.traffic.managent.annotation.ModelBind;
import com.traffic.managent.base.SessionUser;
import com.traffic.managent.jedis.RedisKit;
import com.traffic.managent.plugin.ParamInitThread;

@ModelBind(table = "cx_provider", key = "ids")
public class Provider extends SessionUser<Provider> {

	private static final long serialVersionUID = 1L;
	public static final Provider dao = new Provider();

	public List<Provider> findAll() {
		return Provider.dao.find("select * from cx_provider where delFlag = '0' ");
	}
	/**
	 * 添加或者更新缓存
	 */
	public void cacheAdd(Provider provider) {
		RedisKit.put(ParamInitThread.cacheStart_provider + provider.getStr("channel"), provider);
		RedisKit.put(ParamInitThread.cacheStart_provider + provider.getStr("ids"), provider);
	}
	/**
	 * 删除缓存
	 */
	public void cacheRemove(String ids) {
		Provider provider = dao.findById(ids);
		RedisKit.remove(ParamInitThread.cacheStart_provider + provider.getStr("channel"));
		RedisKit.remove(ParamInitThread.cacheStart_customer + provider.getStr("ids"));
	}
}
